package com.atguigu.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 需要配置spring-boot-starter-actuator jar和@RefreshScope注释进行使用
 * 同时需要手动调用服务
 *      curl -X POST http://localhost:3355/actuator/refresh
 *      来刷新才能实现不重启服务来动态刷新配置
 * @author timiv
 */
@RestController
@RefreshScope
public class ConfigController {

    @Value("${config.info}")
    private String config;

    @Value("${server.port}")
    private String port;

    @GetMapping("/config")
    public String configInfo(){
        return port + "\t" + config;
    }
}
